Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

350
Visualizações
Error encountered during contract execution [stack underflow (0 <=> 2)]

I'm developing an ERC721 contract. Whenever i call my mint function, i get this error :

Error encountered during contract execution [stack underflow (0 <=> 2)]

My function contains nothing but a simple require and return statement.

Any Help would be very much appriciated

I then downgraded to Sol 0.6.6 But i keep getting the same issue. Even meta mask shows this message when im about to confirm the transaction :

enter image description here

This is my Mint function :

function Mint() notBroke external payable returns (uint256) {  

    require(msg.value >= 0.05 ether, 'You didnt pay enough Eth Buddy :/'); 

    return 1;
}

This is My notBroke Modifier :

   modifier notBroke() {
    require(address(this).balance > 0 ether,"You  Broke");
    _;
}

And this is how I am committing the transaction from the Front end (using meta mask) :

        const transactionParameters = {
              to: Contract.address, 
              from: props.account, // must match user's active address.
              value: parseInt(Web3.utils.toWei("0.05", 'ether')).toString(16), 
              data: web3.eth.abi.encodeFunctionCall(    
                {
                    "inputs": [],
                    "name": "Mint",
                    "outputs": [
                      {
                        "internalType": "uint256",
                        "name": "",
                        "type": "uint256"
                      }
                    ],
                    "stateMutability": "payable",
                    "type": "function"
                  },[]
            ),
              chainId: `0x${parseInt(props.network)}`, // Used to prevent transaction reuse across blockchains. Auto-filled by MetaMask.
            };


            await window.ethereum.request({
              method: 'eth_sendTransaction',
              params: [transactionParameters],
            }).then( (result) => {

                 resolve(result) 

            }).catch((error)=> resolve(error))

And this is whats shown on Etherscan :

enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Here you have added modifier Which means your contract should have balance greater then 0, so at first time your contract will have 0 ether so it will revert transaction, please try to check balance of your contract and I think so you should check balance user who want to mint token

about 4 years ago · Juan Pablo Isaza Relatório

0

The modifier throws an exception (effectively reverting the transaction) with message "You Broke" if the contract address (not the sender address) has 0 balance.


If you want to update the modifier to revert only if the sender address has 0 balance, you need to use msg.sender instead of address(this):

require(msg.sender.balance > 0 ether,"You  Broke");
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda